<!DOCTYPE html>
<html>
<head>
    <title>测试</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
          charset="UTF-8"/>
    <link rel="stylesheet" type="text/css" href="../CSS/btn.css"/>

    <script type="text/javascript" src="../js/autoQR.js"></script>
    <script src="../js/HKNativeJSBridge.js"></script>

</head>
<body onload="onloadFinish()">
<div class="box">
    <div class="message" id="message"></div>
    <button class="btn"  onclick="testStore()">测试存储</button>
    <br/>
    <button class="btn"  onclick="testRead()">测试读存储</button>
    <br/>
    <button class="btn"  onclick="testNewPage()">打开新页面push</button>
    <br/>
    <button class="btn"  onclick="testNewPagePop()">打开新页面pop</button>
    <br/>
    <button class="btn"  onclick="testNewOnLinePage()">打开在线新页面</button>
    <br/>
    <button class="btn"  onclick="testDevice()">设备功能</button>
    <br/>
    <button class="btn"  onclick="testLog()">占位</button>
    <br/>
    <button class="btn"  onclick="testLog()">占位</button>
    <br/>
    <button class="btn"  onclick="testLog()">占位</button>
    <br/>
    <button class="btn"  onclick="testLog()">占位</button>
    <br/>
    <button class="btn"  onclick="testLog()">占位1</button>

    <br/>
</div>
<script>

    let nums = 0;
    function onloadFinish() {
        // console.log(document.documentElement.innerHTML);

        console.log("onloadFinish");
    }

    function testStore() {

        hkNativeStore.save({"key": "jsKey", "value": "jsstore content test"},function (message) {

            storeResult(message);
        })
    }

    function storeResult(result) {

        console.log(typeof (result));

        // 字符串转化为Object
        // let obj = eval('(' + result + ')');

        // let obj = result;

        document.getElementById('message').innerHTML = result.status ? "store success" : "store fail";

        console.log("recv" + result);
    }

    function testRead() {

        hkNativeStore.get({"key": "jsKey"},readResult)
    }

    function refreshFun(message) {

        console.log("refreshFun" + message);
    }

    function readResult(result) {

        // let obj = eval('(' + result + ')');
        // let obj = result;


        document.getElementById('message').innerHTML = result.status ? "get success:" + result.data : "get fail";

        console.log("recv" + result);
    }

    function testNewPage() {
        hkNativePage.openPage({url: window.location.href.substring(0,window.location.href.lastIndexOf("/")+1) +"h53.html",type:"push"},function (message) {

            document.getElementById('message').innerHTML = "new page info" + message;
        })
    }
    function testNewPagePop() {

        hkNativePage.openPage({url: window.location.href.substring(0,window.location.href.lastIndexOf("/")+1) +"h53.html",type:"pop"},function (message) {

            document.getElementById('message').innerHTML = "new page info" + message;
        })
    }
    function testNewOnLinePage() {

        hkNativePage.openPage({"url": "https://www.baidu.com"},function (message) {

            document.getElementById('message').innerHTML = "new page info";
        })

    }

    function testDevice()
    {
        hkNativePage.openPage({url: window.location.href.substring(0,window.location.href.lastIndexOf("/")+1) +"h5Device.html",style:"push"},function (message) {

            document.getElementById('message').innerHTML = "new page info" + message;
        })
    }
    function testLog() {

        console.log("js log" + nums);
        nums++;
    }

</script>


</body>
</html>
